//
//  LoadLocalGif.swift
//  ImageBasic
//
//  Created by 李煜 on 2024/7/30.
//

import SwiftUI
import GIFImage

struct LoadLocalGif: View {
    let filePath = Bundle.main.path(forResource: "heartBeats", ofType: "gif")
    // 定义gif动图url
    let url1 = URL(string: "https://hbimg.huaban.com/90698675364a29487b694c79209001b91b407a12328b1-DQsXyW_fw658")!

    let url2 = URL(string: "https://img.zcool.cn/community/01eee15824520da84a0e282beff2dd.gif")!
    var body: some View {
        VStack(content: {
            //加载网络gif
            GIFImage(source: .remoteURL(url1))
                .frame(width: 200)
                .aspectRatio(contentMode: .fit)
            GIFImage(source: .remoteURL(url2))
                .aspectRatio(contentMode: .fit)
            //加载本地gif
            GIFImage(source: .local(filePath: filePath!))
        })
    }
}

#Preview {
    LoadLocalGif()
}
